/*
 * GStandingsRankTendency.java
 * Created on 29 déc. 2007
 *
 * Glacéo Internet Platform
 * http://sourceforge.net/projects/chm/
 *
 * Copyright (c) 2005-2007, Jan Janke (VirtualHockey Project)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hockeo.vhbase.data.helper;

/**
 * Constants indicating the rank tendency (did the club's rank improved, degraded or
 * remained unchanged).
 *
 * @version $Id$
 * @author jjanke
 */
public enum GStandingsRankTendency
{
  IMPROVED( "rank_improved.gif" ),

  UNCHANGED( "rank_unchanged.gif" ),

  DEGRADED( "rank_degraded.gif" );

  private String d_strIcon;

  /** No-arg constrcutor for GWT/RPC. */
  private GStandingsRankTendency()
  {}

  private GStandingsRankTendency( String strIcon )
  {
    d_strIcon = strIcon;
  }

  public String getIcon()
  {
    return d_strIcon;
  }

  /**
   * Returns a rank tendency object based on the current and previous rank.
   *
   * @param nCurrentRank the current rank of the club
   * @param nPreviousRank the previous rank of the same club
   * @return the matching rank tendency indicator object
   */
  public static GStandingsRankTendency valueOf( int nCurrentRank, int nPreviousRank )
  {
    int nRankDiff = nCurrentRank - nPreviousRank;

    if ( nRankDiff == 0 )
      return UNCHANGED;
    else if ( nRankDiff > 0 )
      return DEGRADED;
    else
      return IMPROVED;
  }
}
